<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>PintarOS: include/tea.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">PintarOS
   </div>
   <div id="projectbrief">Operating System for Smart Card</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Groups</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">tea.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>TEA declarations.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;types.h&quot;</code><br/>
</div>
<p><a href="tea_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:aa678b837d257055122c760212507f5cf"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa678b837d257055122c760212507f5cf"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>iu32</b>&#160;&#160;&#160;uint32_t</td></tr>
<tr class="separator:aa678b837d257055122c760212507f5cf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a17cd82048f8180bc8980bf1e8b0a8ffd"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a17cd82048f8180bc8980bf1e8b0a8ffd"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>iu16</b>&#160;&#160;&#160;uint16_t</td></tr>
<tr class="separator:a17cd82048f8180bc8980bf1e8b0a8ffd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a27fca80d38c40153b6a1d9ac3407681b"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a27fca80d38c40153b6a1d9ac3407681b"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>iu8</b>&#160;&#160;&#160;uint8_t</td></tr>
<tr class="separator:a27fca80d38c40153b6a1d9ac3407681b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac52845e68e2ba28492bfe7713ecd4446"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac52845e68e2ba28492bfe7713ecd4446"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#ac52845e68e2ba28492bfe7713ecd4446">TEA_KEY_LEN</a>&#160;&#160;&#160;16</td></tr>
<tr class="memdesc:ac52845e68e2ba28492bfe7713ecd4446"><td class="mdescLeft">&#160;</td><td class="mdescRight">TEA key size. <br/></td></tr>
<tr class="separator:ac52845e68e2ba28492bfe7713ecd4446"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a42fe1c2852561ea40a1380fc426d9c81"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a42fe1c2852561ea40a1380fc426d9c81"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#a42fe1c2852561ea40a1380fc426d9c81">TEA_BLOCK_LEN</a>&#160;&#160;&#160;8</td></tr>
<tr class="memdesc:a42fe1c2852561ea40a1380fc426d9c81"><td class="mdescLeft">&#160;</td><td class="mdescRight">TEA block length. <br/></td></tr>
<tr class="separator:a42fe1c2852561ea40a1380fc426d9c81"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3fd2b1bcd7ddcf506237987ad780f495"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3fd2b1bcd7ddcf506237987ad780f495"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#a3fd2b1bcd7ddcf506237987ad780f495">DELTA</a>&#160;&#160;&#160;0x9E3779B9</td></tr>
<tr class="memdesc:a3fd2b1bcd7ddcf506237987ad780f495"><td class="mdescLeft">&#160;</td><td class="mdescRight">Magic value. (Golden number * 2^31) <br/></td></tr>
<tr class="separator:a3fd2b1bcd7ddcf506237987ad780f495"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a69479655ab94c875413d38689002ff98"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a69479655ab94c875413d38689002ff98"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#a69479655ab94c875413d38689002ff98">ROUNDS</a>&#160;&#160;&#160;32</td></tr>
<tr class="memdesc:a69479655ab94c875413d38689002ff98"><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of rounds. <br/></td></tr>
<tr class="separator:a69479655ab94c875413d38689002ff98"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0e93a14e5e2e0f46131a360584d4a835"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0e93a14e5e2e0f46131a360584d4a835"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#a0e93a14e5e2e0f46131a360584d4a835">swap_us</a>(us)&#160;&#160;&#160;(((us&amp;0x00FF)&lt;&lt;8)|((us&amp;0xFF00)&gt;&gt;8))</td></tr>
<tr class="memdesc:a0e93a14e5e2e0f46131a360584d4a835"><td class="mdescLeft">&#160;</td><td class="mdescRight">Byte swap single short. <br/></td></tr>
<tr class="separator:a0e93a14e5e2e0f46131a360584d4a835"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7d4ae55324da2e40ff7ddd19799c09f6"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7d4ae55324da2e40ff7ddd19799c09f6"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#a7d4ae55324da2e40ff7ddd19799c09f6">swap_ul</a>(ul)&#160;&#160;&#160;(((ul&amp;0x000000FF)&lt;&lt;24)|((ul&amp;0x0000FF00)&lt;&lt;8)|((ul&amp;0x00FF0000)&gt;&gt;8)|((ul&amp;0xFF000000)&gt;&gt;24))</td></tr>
<tr class="memdesc:a7d4ae55324da2e40ff7ddd19799c09f6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Byte swap single long. <br/></td></tr>
<tr class="separator:a7d4ae55324da2e40ff7ddd19799c09f6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3ac6738fd6414caf56af16d5aa3cc27e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3ac6738fd6414caf56af16d5aa3cc27e"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>hton_us</b>(us)</td></tr>
<tr class="separator:a3ac6738fd6414caf56af16d5aa3cc27e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab1151e3852ea534254b55edcc7c2492a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab1151e3852ea534254b55edcc7c2492a"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>hton_ul</b>(ul)</td></tr>
<tr class="separator:ab1151e3852ea534254b55edcc7c2492a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac6afabdc09a49a433ee19d8a9486056d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#ac6afabdc09a49a433ee19d8a9486056d">min</a>(a, b)&#160;&#160;&#160;((a)&lt;(b)?(a):(b))</td></tr>
<tr class="separator:ac6afabdc09a49a433ee19d8a9486056d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:affe776513b24d84b39af8ab0930fef7f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#affe776513b24d84b39af8ab0930fef7f">max</a>(a, b)&#160;&#160;&#160;((a)&gt;(b)?(a):(b))</td></tr>
<tr class="separator:affe776513b24d84b39af8ab0930fef7f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a982d969b3496c4117d0079f91048a5ba"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#a982d969b3496c4117d0079f91048a5ba">hton_us</a> (uint16_t *us, uint8_t num)</td></tr>
<tr class="memdesc:a982d969b3496c4117d0079f91048a5ba"><td class="mdescLeft">&#160;</td><td class="mdescRight">Byte swap multiple shorts.  <a href="#a982d969b3496c4117d0079f91048a5ba">More...</a><br/></td></tr>
<tr class="separator:a982d969b3496c4117d0079f91048a5ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa8f61bcad3e32a5a398164a3de6ba287"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#aa8f61bcad3e32a5a398164a3de6ba287">hton_ul</a> (uint32_t *ul, uint8_t num)</td></tr>
<tr class="memdesc:aa8f61bcad3e32a5a398164a3de6ba287"><td class="mdescLeft">&#160;</td><td class="mdescRight">Byte swap multiple longs.  <a href="#aa8f61bcad3e32a5a398164a3de6ba287">More...</a><br/></td></tr>
<tr class="separator:aa8f61bcad3e32a5a398164a3de6ba287"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a542935b6cd737dab8bf9c5bbfc10dbf0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#a542935b6cd737dab8bf9c5bbfc10dbf0">tea_enc</a> (uint32_t *v, uint32_t *k)</td></tr>
<tr class="memdesc:a542935b6cd737dab8bf9c5bbfc10dbf0"><td class="mdescLeft">&#160;</td><td class="mdescRight">TEA encryption function.  <a href="#a542935b6cd737dab8bf9c5bbfc10dbf0">More...</a><br/></td></tr>
<tr class="separator:a542935b6cd737dab8bf9c5bbfc10dbf0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aca30c56208449c7ff223be556d98df80"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="tea_8h.html#aca30c56208449c7ff223be556d98df80">tea_dec</a> (uint32_t *v, uint32_t *k)</td></tr>
<tr class="memdesc:aca30c56208449c7ff223be556d98df80"><td class="mdescLeft">&#160;</td><td class="mdescRight">TEA decryption function.  <a href="#aca30c56208449c7ff223be556d98df80">More...</a><br/></td></tr>
<tr class="separator:aca30c56208449c7ff223be556d98df80"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>TEA declarations. </p>
<p>Documentation for TEA is available at <a href="http://www.cl.cam.ac.uk/ftp/users/djw3/tea.ps">http://www.cl.cam.ac.uk/ftp/users/djw3/tea.ps</a>.</p>
<dl class="section rcs"><dt>Id:</dt><dd><a class="el" href="tea_8h.html" title="TEA declarations. ">tea.h</a>,v 1.5 2002/12/22 15:42:55 m Exp </dd></dl>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="affe776513b24d84b39af8ab0930fef7f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define max</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">a, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">b&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;((a)&gt;(b)?(a):(b))</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Return maximum value </p>

</div>
</div>
<a class="anchor" id="ac6afabdc09a49a433ee19d8a9486056d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define min</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">a, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">b&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;((a)&lt;(b)?(a):(b))</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Return minimum value </p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="aa8f61bcad3e32a5a398164a3de6ba287"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void hton_ul </td>
          <td>(</td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>ul</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>num</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Byte swap multiple longs. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ul</td><td>Pointer to an array of longs. </td></tr>
    <tr><td class="paramname">num</td><td>Number of longs to process. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a982d969b3496c4117d0079f91048a5ba"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void hton_us </td>
          <td>(</td>
          <td class="paramtype">uint16_t *&#160;</td>
          <td class="paramname"><em>us</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>num</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Byte swap multiple shorts. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">us</td><td>Pointer to an array of shorts. </td></tr>
    <tr><td class="paramname">num</td><td>Number of shorts to process. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aca30c56208449c7ff223be556d98df80"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void tea_dec </td>
          <td>(</td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>v</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>k</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>TEA decryption function. </p>
<p>This function decrypts <em>v</em> with <em>k</em> and returns the decrypted data in <em>v</em>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">v</td><td>Array of two long values containing the data block. </td></tr>
    <tr><td class="paramname">k</td><td>Array of four long values containing the key. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a542935b6cd737dab8bf9c5bbfc10dbf0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void tea_enc </td>
          <td>(</td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>v</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>k</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>TEA encryption function. </p>
<p>This function encrypts <em>v</em> with <em>k</em> and returns the encrypted data in <em>v</em>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">v</td><td>Array of two long values containing the data block. </td></tr>
    <tr><td class="paramname">k</td><td>Array of four long values containing the key. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Jun 4 2014 18:13:31 for PintarOS by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.5
</small></address>
</body>
</html>
